import type { TableColumn } from '@/framework/components/core/super-table';
import { ref } from 'vue';
import { commonCode } from '@/api/common/common_code';
export const clientType = ref();
/**
 * columns
 */
export type TableListItem = {
  id;
  type;
  version;
  note;
  url;
  createTime;
};
export type TableColumnItem = TableColumn<TableListItem>;

export const baseColumns: TableColumnItem[] = [
  {
    type: 'seq',
    title: '序号',
    width: 60,
  },
  {
    title: '客户端类型',
    field: 'type',
    formatter: ({ cellValue }) => {
      return clientType.value?.find((item) => item?.value === cellValue)?.label ?? '';
    },
    formItemProps: {
      component: 'Select',
      componentProps: {
        request: async () => {
          const res = await commonCode('upgrade_type');
          return (clientType.value = res.result.map((item) => ({
            label: item.name,
            value: item.code,
          })));
        },
      },
    },
  },
  {
    title: '版本号',
    field: 'version',
    hideInSearch: true,
  },
  {
    title: '版本说明',
    field: 'note',
    hideInSearch: true,
  },
  {
    title: '安装包路径',
    field: 'url',
    hideInSearch: true,
  },
  {
    title: '创建时间',
    field: 'createTime',
    hideInSearch: true,
  },
];
